package com.xinhua.erp.controller;

import com.xinhua.erp.pojo.Pay;
import com.xinhua.erp.pojo.Result;
import com.xinhua.erp.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("pay")
public class PayController {

    @Autowired
    private PayService payService;


    @GetMapping("{id}")
    public Result findById(@PathVariable Long id){
        return payService.findById(id);
    }

    @GetMapping("{type}/{page}/{size}")
    public Result findByType(@PathVariable String type,@PathVariable int page,@PathVariable int size){
        return payService.findPayByType(type,page,size);
    }

    @GetMapping("type/{type}")
    public Result findAll(@PathVariable String type){
        return payService.findAllByType(type);
    }

    @DeleteMapping("{id}")
    public  Result deleteById(@PathVariable Long id){
        return payService.deleteById(id);
    }

    @PostMapping
    public Result save(@RequestBody Pay pay){
        return payService.save(pay);
    }

    @PutMapping("{id}")
    public Result update(@PathVariable Long id,@RequestBody Pay pay){
        return payService.update(id,pay);
    }

    @PostMapping("search/{page}/{size}")
    public Result Search(@RequestBody Map searchMap, @PathVariable int page, @PathVariable int size){
        return payService.Search(searchMap,page,size);
    }
}
